import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'
Vue.use(ElementUI);

axios.defaults.baseURL = 'http://127.0.0.1:8000'
Vue.prototype.$axios = axios

axios.interceptors.request.use((req=>{
  console.log('req>>>>>>>>>>>',req)
  req.headers.token = localStorage.getItem('token')
  
  return req
}))

axios.interceptors.response.use((resp=>{
  console.log('resp>>>>>>>>',resp)
  if(resp.data.code==403){
    alert(resp.data.msg)
    router.push('/')
  }
  
  return resp
}))

new Vue({
  router,
  store,
  render: function (h) { return h(App) }
}).$mount('#app')
